/**
 * 
 */
package uk.co.lunagroup.vladar.oncentersanity;

import java.text.ParseException;

/**
 * This maps the data types of onScreen. For now it is not used, but class is functional. also methods get() set() are working.
 * method copying data from String[][] array to OnScreenDataType[] should work as well
 * XXX needs testing and development
 * 
 * @author robert.kowalski
 *
 */
public class OnScreenDataType {

	private String conditionNr;
	private String conditionName;
	private String height;
	private String area;
	private double qty1;
	private String uom1;
	private double qty2;
	private String uom2;
	private double qty3;
	private String uom3;
	
	
	/**
	 * 
	 */
	public OnScreenDataType(String column0, String column1, String column2, String column3, double column4, String column5,
			double column6, String column7, double column8, String column9) {
			// constructor stub
			this.conditionNr=column0;
			this.conditionName=column1;
			this.height=column2;
			this.area=column3;
			this.qty1=column4;
			this.uom1=column5;
			this.qty2=column6;
			this.uom2=column7;
			this.qty3=column8;
			this.uom3=column9;	
	}
	
	public String getConditionNr() {
	    return conditionNr;
	}
	
	public void setConditionNr(String Nr) {
		this.conditionNr=Nr;
	}
	
	public String getConditionName() {
		return conditionName;
	}
	
	public void setConditionName(String Name) {
		this.conditionName=Name;
	}
	
	public String getHeight() {
		return height;
	}
	
	public void setHeight(String height) {
		this.height=height;
	}	
	
	public String getArea() {
		return area;
	}
	
	public void setArea(String inputArea) {
		this.area=inputArea;
	}	
	
	public double getQty1() {
		return qty1;
	}
	
	public void setQty1(double inputQty) {
		this.qty1=inputQty;
	}	
	
	public String getUom1() {
		return uom1;
	}
	
	public void setUom1(String inputUom) {
		this.uom1=inputUom;
	}
	public double getQty2() {
		return qty2;
	}
	
	public void setQty2(double inputQty) {
		this.qty2=inputQty;
	}	
	
	public String getUom2() {
		return uom2;
	}
	
	public void setUom2(String inputUom) {
		this.uom2=inputUom;
	}
	
	public double getQty3() {
		return qty3;
	}
	
	public void setQty3(double inputQty) {
		this.qty3=inputQty;
	}	
	
	public String getUom3() {
		return uom3;
	}
	
	public void setUom3(String inputUom) {
		this.uom3=inputUom;
	}
	
	public static OnScreenDataType[] createOnScreenArray(String [][] inputArray) throws ParseException {
		int rowNum=ArrayOperations.checkArrayYSize(inputArray);
		//declare the storage container.
		OnScreenDataType[] onScreenArray = new 	OnScreenDataType[rowNum]; //important!! if it will be null will get error
		
		String[] title= {"No", "Name", "Height", "Area", "Qty1" , "Uom1", "Qty2", "Uom2", "Qty3", "Uom3"}; //Keep title row in separate array
		
		//copy String[][] array into OnScreenData Array. starting with 2nd row (first keeping as title
		 					 	
			for (int i=1; i<rowNum;i++) {
				onScreenArray[i]=new OnScreenDataType("test", "test", "test", "test", 1, "test", 2, "test", 3, "test");//required !!! otherwise error
				onScreenArray[i].setConditionNr(inputArray[0][i]);
				onScreenArray[i].setConditionName(inputArray[1][i]);
				onScreenArray[i].setHeight(inputArray[2][i]);
				onScreenArray[i].setArea(inputArray[3][i]);
				
				double qty1=StringOperations.convertStringToDouble(inputArray[4][i]);
				onScreenArray[i].setQty1(qty1); 
				onScreenArray[i].setUom1(inputArray[5][i]);
				
				double qty2=StringOperations.convertStringToDouble(inputArray[6][i]);
				onScreenArray[i].setQty2(qty2);
				onScreenArray[i].setUom2(inputArray[7][i]);
				
				double qty3=StringOperations.convertStringToDouble(inputArray[7][i]);
				onScreenArray[i].setQty3(qty3);
				onScreenArray[i].setUom3(inputArray[9][i]);
			}
				
			
	return onScreenArray;
	}
	
	
	
	
}
